<?php
namespace modules\post\action\show\posts;

use library\PageAction;
use idea\ap\Ap;
use helper\Util;

/**
 * ListAction class file
 * 文档列表展示
 * @author 宋欢 <iphper@yeah.net>
 * @version $Id: ListAction.php 1 2013-02-08 00:48:06Z huan.song $
 * @package modules.post.action.show.posts
 * @since 1.0
 */
class ListAction extends PageAction
{
	/**
	 * (non-PHPdoc)
	 * @see idea\mvc\interfaces.Action::run()
	 */
	public function run()
	{
		$request = Ap::getRequest();
		$params = array();
		
		if (($value = $request->getInteger('category_id')) > 0) {
			$params['category_id'] = $value;
		}
		
		if (($value = $request->getTrim('post_flags')) !== '') {
			$params['post_flags'] = $value;
		}
		
		if (($value = $request->getTrim('post_status')) !== '') {
			$params['post_status'] = $value;
		}

		$ret = Util::getService('Posts', 'post')->search($params, $request->getTrim('order_by'));
		$this->render($ret);
	}
}
